package com.yanqu.road.entity.activity.newyearbag;

import java.util.concurrent.ConcurrentHashMap;

/**
 * 实物限制
 */
public class NewYearBagShiWuLimitData {

    private int day;
    //itemId
    private ConcurrentHashMap<Integer, Long> map = new ConcurrentHashMap<>();

    // ----------------------------------------
    public NewYearBagShiWuLimitData(int day) {
        this.day = day;
    }

    public NewYearBagShiWuLimitData() {
    }

    public long getAllNum() {
        return map.values().stream().mapToLong(Long::longValue).sum();
    }

    public long getTodayNum(int itemId) {
        return map.getOrDefault(itemId, 0L);
    }

    public void addNum(int itemId, long num) {
        long oldVal = map.getOrDefault(itemId, 0L);
        map.put(itemId, oldVal + num);
    }

    public int getDay() {
        return day;
    }

    public ConcurrentHashMap<Integer, Long> getMap() {
        return map;
    }
}
